package com.example.shopping.dao;

import com.example.shopping.pojo.SpecificationOption;
import com.example.shopping.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.annotation.Id;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
Create by 苍狼 于 2020/1/16
站在巅峰看世界，
落在深渊思人生。
*/
@Repository
//规格选项
public interface ISpecificationOptionDao {
    //查询全部规格选项
    @Select("select * from specification_option")
    List<SpecificationOption> SelectListSpecificationOption();

    //新增规格选项
    @Insert("insert into specification_option(option_name,spec_id,`order`) values(#{optionName},#{specId},#{order})")
    int insertSpecificationOption(SpecificationOption specificationOption);

    //根据ID删除规格选项
    @Delete("delete from specification_option where id=#{id}")
    int deleteSpecificationById(int id);

    //关联查询
    @Select("select * from specification_option where spec_id=#{specId}")
    SpecificationOption selectListSpecificationOptionByCopyId(int specId);

    //修改方法
    @Update("update specification_option set option_name=#{optionName},order=#{order} where id= id")
    int updateSpecificationOptionById(SpecificationOption specificationOption);

}
